﻿using System;
using System.Text;
using System.Collections.Generic;

namespace Ayatta.Contract.Domain
{

    #region AccountRecharge
    /// <summary>
    /// 充值
    /// </summary>
    public class AccountRecharge : BaseEntity<string>
    {
        /// <summary>
        /// 
        /// </summary>
        /// <value></value>
        public int UserId { get; set; }

        /// <summary>
        /// 0账户充值 1拍币充值 2游戏充值
        /// </summary>
        /// <value></value>
        public RechargeCategory Category { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <value></value>
        public int PackageId { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <value></value>
        public decimal Amount { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <value></value>
        public decimal Discount { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <value></value>
        public decimal Total { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <value></value>
        public string Gateway { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <value>((0))</value>
        public bool ForUser { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <value>((0))</value>
        public int ForUserId { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <value>('')</value>
        public string ForUserName { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <value>((0))</value>
        public int GameId { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <value>((0))</value>
        public int ServerId { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <value></value>
        public string ForeignKey { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <value></value>
        public string Extra { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <value>((0))</value>
        public bool Status { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <value>((0))</value>
        public bool SubStatus { get; set; }

        /// <summary>
        /// 支付明细
        /// </summary>
        public AccountPayment Payment { get; set; }

        /// <summary>
        /// 生成22位随机字符做为Id
        /// </summary>
        public static string NewId()
        {
            const string str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

            var time = DateTime.Now;
            var sb = new StringBuilder()
                .Append(time.ToString("yyMMddHHmm"));

            var b = new byte[4];
            new System.Security.Cryptography.RNGCryptoServiceProvider().GetBytes(b);
            var r = new Random(BitConverter.ToInt32(b, 0));

            for (var i = 0; i < 12; i++)
            {
                sb.Append(str.Substring(r.Next(0, str.Length - 1), 1));
            }
            return sb.ToString();
        }

    }

    #endregion

}